<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../css/common/common.css" />
		<link rel="stylesheet" type="text/css" href="../../css/settings/change.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">更改密码</h1>
		</header>
		<div class="mui-content">
			<div class="main">
				<form class="mui-input-group">
					<div class="mui-input-row">
						<input type="password" class="mui-input-clear oldPassword" placeholder="请输入原始密码" maxlength="12" minlength="6">
					</div>
					<div class="mui-input-row">
						<input type="password" class="mui-input-clear newPassword1" placeholder="请输入新密码" maxlength="12" minlength="6">
					</div>
					<div class="mui-input-row">
						<input type="password" class="mui-input-clear confirmPassword" placeholder="确认新密码" maxlength="12" minlength="6">
					</div>
				</form>
				<div class="confirm"><button type="button" class="mui-btn mui-btn-primary">确 认</button></div>
			</div>
		</div>
		
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/libs/zepto_1.1.3.js"></script>
		<script src="../../js/libs/vue.js"></script>
		<script src="../../js/common/common.js"></script>
		<script type="text/javascript">
			mui.init()
				(function() {
					$(".confirm").on("tap", function() {
						if($(".oldPassword").val() == "") {
							mui.toast("原始密码不能为空")
							return
						} else if($(".newPassword1").val() == "") {
							mui.toast("新密码不能为空")
							return
						} else if($(".confirmPassword").val() == "") {
							mui.toast("新密码不能为空")
							return
						}else if($(".newPassword1").val().length<6||$(".newPassword1").val().length>12) {
							mui.toast("新密码长度不能少于6位或大于12位")
							return
						}else if($(".confirmPassword").val().length<6||$(".confirmPassword").val().length>12) {
							mui.toast("新密码长度不能少于6位或大于12位")
							return
						}
						console.log($(".newPassword1").val().length);
						common.ajax("student/resetPasswordWithOld", {
							uid: common.uid,
							token: common.token,
							oldPassword: $(".oldPassword").val(),
							password1: $(".newPassword1").val(),
							password2: $(".confirmPassword").val()
						}, function(data) {
							console.log(data)
							if(data.code == 200) {
								mui.toast("修改成功");
								mui.back();
							} else {
								mui.toast("修改失败")
							}
						})
					})
					common.focu(".mui-input-clear", "green");
				})()
		</script>
	</body>

</html>